/*jslint browser: true, cap: false, glovar: true, passfail: false, undef: false, white: false */
/*global SONGHAY YAHOO */

(function(){

    //Module-level members:
    var root = SONGHAY;

    SONGHAY.ui.Dom =
    {
        alert:function(vHeader,vMessage,fRef)
        {
            root.ui.alertDialog =
                new YAHOO.widget.SimpleDialog(
                'alertDialog', 
                {
                    width: '300px',
                    fixedcenter: true,
                    visible: false,
                    draggable: false,
                    close: false,
                    modal:true,
                    text: vMessage,
                    icon: YAHOO.widget.SimpleDialog.ICON_INFO,
                    constraintoviewport: true,
                    buttons: [ {text:'Ok', handler:fRef, isDefault:true} ]
                });

            if(vHeader) { root.ui.alertDialog.setHeader(vHeader); }
            root.ui.alertDialog.render(document.body);
            root.ui.alertDialog.show();
        },

        confirm:function(vHeader,vMessage,fRef)
        {
            root.ui.confirmDialog =
                new YAHOO.widget.SimpleDialog(
                'confirmDialog', 
                {
                    width: '300px',
                    fixedcenter: true,
                    visible: false,
                    draggable: false,
                    close: false,
                    modal:true,
                    text: vMessage,
                    icon: YAHOO.widget.SimpleDialog.ICON_HELP,
                    constraintoviewport: true,
                    buttons: [ { text:'Yes', handler:fRef, isDefault:true },{ text:'No',  handler:function(){ this.hide(); } } ]
                });

            root.ui.confirmDialog.setHeader(vHeader);
            root.ui.confirmDialog.render(document.body);
            root.ui.confirmDialog.show();
        },

        getParentElement:function()
        {
            if(arguments.length != 2) { return null; }

            var oChild = arguments[0];
            var oParent = null;
            while(oChild.parentNode && (oParent === null))
            {
                if((oChild.parentNode.nodeType == 1) && (oChild.parentNode.tagName.toLowerCase() == arguments[1]))
                {
                    oParent = oChild.parentNode;
                }
                else
                    { oChild = oChild.parentNode; }
            }

            return oParent;
        }
    };

})();
